Make Save button respond properly on changes in NTP Servers section while editing a Zone #6162
+23
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1749841
Save button did not respond properly on changes in NTP Servers section while editing an existing Zone. Let me explain the fix. Here, the same as in other screens, values of
@edit[:new]
and@edit[:current]
are crucial for detecting changes in the fields and response of Add/Save buttons. In our case, we need to take care of@edit[:new][:ntp]
and@edit[:current][:ntp]
.Beginning of editing a Zone:
After we make some change and put it back, the result will look like this:
We are adding something extra to
@edit[:new][:ntp]
. We always just add something, not remove. And this is core of the problem why Save button remained always enabled if we touched anything in NTP Servers section, no matter we really made a change or not.So we need to remove unnecessary key
"ntp_server_2"
from@edit[:new][:ntp]
to achieve proper response of Save button. And as we can see that the field/server numbers in the loop are from 1 to 3, we have to look atfield_num - 1
th item in the array of@edit[:new][:ntp][:server]
to remove the right key from@edit[:new][:ntp]
as the second position (field_num == 2) in array is in position 1, obviously.After: (Save button becomes disabled after we put back the original values in fields in NTP Servers)